// import base85 from 'base85';
import ascii85 from 'ascii85';

export default class Base85 {
  static Options = {
    encoding: {
      type: 'radio',
      options: [
        {label: 'Ascii85', value: 'ascii85'},
        {label: 'ZeroMQ', value: 'z85'},
        // {label: 'IPv6', value: 'ipv6'},
      ],
    },
  }

  options = {
    encoding: 'ascii85',
  }

  static Encoder = class Encoder extends Base85 {
    static Name = "Base85 <%= UIText.encode %>";

    compute(data) {
      let code = () => {
        switch(this.options.encoding) {
          case 'ascii85':
            return ascii85.encode(data);
          case 'z85':
            return ascii85.ZeroMQ.encode(data);
        }
      }
      return code().toString();
    }
  }

  static Decoder = class Decoder extends Base85 {
    static Name = "Base85 <%= UIText.decode %>";

    compute(text) {
      switch(this.options.encoding) {
        case 'ascii85':
          return ascii85.decode(text);
        case 'z85':
          return ascii85.ZeroMQ.decode(text);
      }
    }
  }
}
